import re


# 将匹配的数字乘以 2
def double(matched):
    print(matched)
    print(matched.group('values'))  # ?P<value> 取一个组名，使用 group('values')可以获取相应值
    value = int(matched.group('values'))
    return str(value * 2)


s = 'A23G4HFD567'
print(re.sub('(?P<values>\d+)', double, s))
